package com;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class SmallGame extends JFrame {
    JLabel jl;
    JButton jb1,jb2;
    static int  report1;
    SmallGame(){

    }
    SmallGame(String s){
        setTitle(s);
        init();
        setVisible(true);
        setBounds(550,300,300,150);
    }
    public void init()
    {
        setLayout(null);
        jl= new JLabel("请做出你的选择");
        jl.setBounds(100,20,120,20);
        jb1 = new JButton("战斗");
        jb1.setBounds(60,70,60,30);
        //jb2 = new JButton("逃跑");
        //jb2.setBounds(180,70,60,30);
        this.add(jl);
        this.add(jb1);
       // this.add(jb2);
        jb1.addActionListener(
                new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        int x=(int)(Math.random()*2);
                        if(x==0)
                        {
                            new Lost();
                            report1= -2;
                            setVisible(false);
                        }
                        else{
                            new win();
                            report1=2;
                        setVisible(false);
                        }
                    }
                }
        );
        //jb2.addActionListener(new ActionListener() {

           // public void actionPerformed(ActionEvent e) {
              //  new foot();
               // report1=-1;
              //  setVisible(false);
            }
       // });
    }
//}
